<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增获奖信息核对')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-check-add">
            <input id="curDeptId" name="curDeptId" type="hidden" th:value="${curDeptId}"   />
            <input id="schoolId" name="schoolId" type="hidden" th:value="${school?.deptId}"   />
            <input id="facultyId" name="facultyId" type="hidden" th:value="${faculty?.deptId}"   />
            <input id="hasPermission" name="hasPermission" type="hidden" th:value="${hasPermission}"/>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">学校：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input class="form-control" type="text" onclick="selectSchool()" id="school" name="school" readonly="true" th:value="${school?.deptName}" required>
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">院系：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input class="form-control" type="text" onclick="selectFaculty()" id="faculty" name="faculty" readonly="true" th:value="${faculty?.deptName}" required>
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label  is-required">大赛名称：</label>
                <div class="col-sm-8">
                    <select id="gameId" name="gameId" class="form-control" th:with="games=${games}" required>
                        <option th:each="game : ${games}" th:text="${game.name}" th:value="${game.id}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">参赛编号：</label>
                <div class="col-sm-8">
                    <input name="actNo" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">错误信息：</label>
                <div class="col-sm-8">
                    <textarea name="errorInfo" class="form-control" rows="6" required></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required" >修正信息：</label>
                <div class="col-sm-8">
                    <textarea name="updateInfo" class="form-control" rows="6" required></textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "system/check"
        $("#form-check-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-check-add').serialize(),function(){
                    $.modal.closeLoading();
                    $.modal.alertWarning("我们将与有作者签名的报名表核对确认后方可更改，请知悉！谢谢！");
                });
            }
        }
        /*选择学校-选择父部门树*/
        function selectSchool() {
            var hasPermission = $("#hasPermission").val();
            if(hasPermission == 'false'){return;}
            var curDeptId = $("#curDeptId").val();
            var prefix = ctx + "system/dept";
            var options = {
                title: '学校选择',
                width: "380",
                url: prefix + "/selectDeptTree/" + curDeptId,
                callBack: doSubmitSchool
            };
            $.modal.openOptions(options);
        }

        function doSubmitSchool(index, layero){
            var body = $.modal.getChildFrame(index);
            $("#schoolId").val(body.find('#treeId').val());
            $("#school").val(body.find('#treeName').val());
            $.modal.close(index);
        }


        /*选择院系-选择父部门树*/
        function selectFaculty() {
            var hasPermission = $("#hasPermission").val();;
            if(hasPermission == 'false'){return;}
            var curDeptId = $("#curDeptId").val();
            var prefix = ctx + "system/dept";
            var options = {
                title: '院系选择',
                width: "380",
                url: prefix + "/selectDeptTree/" + curDeptId,
                callBack: doSubmitFaculty
            };
            $.modal.openOptions(options);
        }

        function doSubmitFaculty(index, layero){
            var body = $.modal.getChildFrame(index);
            $("#facultyId").val(body.find('#treeId').val());
            $("#faculty").val(body.find('#treeName').val());
            $.modal.close(index);
        }
    </script>
</body>
</html>